The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
META.yml 34
Makefile.PL 55
SIGNATURE 88
lib/MooseX/Role/Restricted.pm 1631
4 files changed (This is a version diff) 3248
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:               MooseX-Role-Restricted
-version:            1.02
+version:            1.03
 abstract:           ~
 author:
     - Graham Barr <gbarr@pobox.com>
@@ -9,8 +9,9 @@ distribution_type:  module
 configure_requires:
     ExtUtils::MakeMaker:  0
 requires:
-    Moose:       0.72
-    Test::More:  0
+    Attribute::Handlers:  0.88
+    Moose:                0.90
+    Test::More:           0
 no_index:
     directory:
         - t
@@ -8,10 +8,10 @@ WriteMakefile(
   AUTHOR       => 'Graham Barr <gbarr@pobox.com>',
   VERSION_FROM => 'lib/MooseX/Role/Restricted.pm',
   PL_FILES     => {},
-  PREREQ_PM => {
-    'Moose'      => '0.72',
-    'Test::More' => 0,
-    },
-  dist     => {COMPRESS => 'gzip -9f', SUFFIX => 'gz',},
+  PREREQ_PM    => {
+    'Moose'               => '0.90',
+    'Test::More'          => 0,
+    'Attribute::Handlers' => 0.88,
+  },
 );
 
@@ -1,5 +1,5 @@
 This file contains message digests of all files listed in MANIFEST,
-signed via the Module::Signature module, version 0.55.
+signed via the Module::Signature module, version 0.64.
 
 To verify the content in this distribution, first make sure you have
 Module::Signature installed, then type:
@@ -15,15 +15,15 @@ not run its Makefile.PL or Build.PL.
 Hash: SHA1
 
 SHA1 5cc470b27fef88b01e090b1c9a782ac4c34f5057 MANIFEST
-SHA1 cc0fdd6c5c93ab0456665c73485feaa11ccba880 META.yml
-SHA1 1bd5b3ab6377d6d552a6768fc84397585a025d10 Makefile.PL
+SHA1 860866409d7d541ff0f8aee3d6e7989d6094b1e5 META.yml
+SHA1 0a07026261c35456bcb64c404fa278cf5046bdd4 Makefile.PL
 SHA1 4d3c0dd415bd745aec2bb7f30aa815b2bf1254f0 README
-SHA1 766cad3b08f187090c87abeb573a43fd71d981ff lib/MooseX/Role/Restricted.pm
+SHA1 38f9fd4cee576f3920e2ae68717808fe60ea9645 lib/MooseX/Role/Restricted.pm
 SHA1 4e1b06af171c45196c8682f25605956e7b43a3d9 t/basic.t
 -----BEGIN PGP SIGNATURE-----
-Version: GnuPG v1.4.10 (Darwin)
+Version: GnuPG v1.4.11 (Darwin)
 
-iEYEARECAAYFAkrYe6YACgkQR0BL4gbYw3Qj2wCeMVMaC4XATtU6ef1/lN5DxDN1
-Z2wAniMIBpsYkecA0RrtfMfajRsxWlbl
-=ifIM
+iEUEARECAAYFAk0vHPcACgkQR0BL4gbYw3Sq6ACYkCKgllAWZnXerRvh5SEf5MQC
+JACeJuVXhn+aVBbxk87aKldqt9GTXjw=
+=nmHw
 -----END PGP SIGNATURE-----
@@ -1,12 +1,15 @@
 package MooseX::Role::Restricted;
 
-our $VERSION = '1.02';
+our $VERSION = '1.03';
 
 use Moose::Role;
 use Moose::Exporter;
 use Attribute::Handlers;
 
-Moose::Exporter->setup_import_methods(also => 'Moose::Role');
+Moose::Exporter->setup_import_methods(
+  also  => 'Moose::Role',
+  as_is => [qw(_ATTR_CODE_Public _ATTR_CODE_Private)],
+);
 
 sub Public : ATTR(CODE) {
   my ($package, $symbol, $referent, $attr, $data) = @_;
@@ -20,6 +23,9 @@ sub Private : ATTR(CODE) {
   $package->meta->public_private_map->{$name} = 1;
 }
 
+# fudge due to delayed resolve in A::H, needed to defined _ATTR_CODE_Private
+sub PPP : ATTR(CODE) { }
+
 sub init_meta {
   my ($class, %opt) = @_;
   my $meta = Moose::Role->init_meta(    ##
@@ -27,11 +33,6 @@ sub init_meta {
     metaclass => 'MooseX::Role::Restricted::Meta'
   );
 
-  # For the sub attributes to work, the role package needs to inherit from us
-  unless ($opt{for_class}->isa(__PACKAGE__)) {
-    my $isa = $meta->get_package_symbol('@ISA');
-    push @$isa, __PACKAGE__;
-  }
   $meta;
 }
 
@@ -51,16 +52,18 @@ sub apply {
   my ($self, $other, %args) = @_;
   my $pp_map = $self->public_private_map;
   my @exclude = grep { exists $pp_map->{$_} ? $pp_map->{$_} : /^_/; } $self->get_method_list;
-  if (exists $args{excludes}) {
-    $args{excludes} = push @exclude,
-      (
-      ref $args{excludes} eq 'ARRAY'
-      ? @{$args{excludes}}
-      : $args{excludes}
-      );
+
+  if (exists $args{excludes} && !exists $args{'-excludes'}) {
+    $args{'-excludes'} = delete $args{excludes};
+  }
+
+  if (exists $args{'-excludes'}) {
+    push @exclude, (ref $args{'-excludes'} eq 'ARRAY')
+      ? @{$args{'-excludes'}}
+      : $args{'-excludes'};
   }
 
-  $args{'excludes'} = \@exclude;
+  $args{'-excludes'} = \@exclude;
   $self->SUPER::apply($other, %args);
 }
 
@@ -70,7 +73,7 @@ __END__
 
 =head1 NAME
 
-  MooseX::Role::Restricted - Restrict which sub are exported by a role
+  MooseX::Role::Restricted - (DEPRECATED) Restrict which sub are exported by a role
 
 =head1 SYNOPSIS
 
@@ -84,6 +87,18 @@ __END__
   sub _method2 :Public { ... }
   sub private2 :Private { ... }
 
+=head1 DEPRECATED
+
+This module is no longer supported. I suggest looking at L<namespace::autoclean> as an alternative.
+In its default form L<MooseX::Role::Restricted> simple excludes ann sub with names starting with C<_>
+to be excluded. This can be accomplished using
+
+  use namespace::autoclean -also => qr/^_/;
+
+If you are using C<lazy_build> or other L<Moose> features that require the use of C<_> prefixed methods
+make sure to change the pattern to not match those. Or use some other prefix, for example a double 
+C<_>, for your private subs that you do not want included in the role.
+
 =head1 DESCRIPTION
 
 By default L<Moose::Role> will export any sub you define in a role package. However